class ContactApi < Grape::API
  format 'json'
  
  namespace :contacts do

    desc '新增联系人'
    params do
      requires :companies_id, type: Integer
      requires :name, type: String
      requires :tel_no, type: String 
      optional :gender, type: Integer
      optional :dept_name, type: String
      optional :important_level, type: Integer
      optional :phone_no, type: String
      optional :email, type: String
      optional :note, type: String
    end
    post 'add_contact' do
      content_type 'application/json'
      ContactService.add(params)
    end

    desc '查询联系人信息'
    params do
      requires :companies_id, type: Integer
    end
    get 'query_contacts_by_companies_id' do
      ContactService.query_contacts_by_companies_id(params[:companies_id])
    end

  end
  
end
